package eleven;

import java.util.ArrayList;
import java.util.Scanner;

public class eleven_seventh {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        ArrayList<Integer> num=new ArrayList<>();
        System.out.println("Enter an integer m:");
        int m=input.nextInt();
        int x=m;
        for(int i=2;i<=Math.sqrt(m);i++){
            if(sushu(i)) {
                if (x % i == 0) {
                    x /= i;
                    num.add(i);
                    i--;
                }
                if (x == 1) {
                    break;
                }
            }

        }
        int n=1;
        int cnt=1;
        for(int i:num){
            if((occurs(i,num))%2!=0 &&cnt!=i){
                n*=i;
                cnt=i;

            }
        }
        System.out.println("The smallest number n for n*m to be a perfect number is "+n);
        int ans=n*m;
        System.out.println(n+" * "+m+" is "+ans);




    }
    public static boolean sushu(int x){

        for(int i=2;i<=Math.sqrt(x);i++){
            if(x%i==0){
                return  false;
            }
        }
        return true;
    }
    public static int occurs(int x,ArrayList<Integer> l){
        int count=0;
        for(int i:l){
            if(i==x){
                count++;
            }
        }
        return count;
    }
}
